import axios from 'axios'
export default {
  namespaced: true,
  state: {
    token: '',
    userInfo: {}
  },
  mutations: {
    updateToken (state, token) {
      state.token = token
    },
    updateUserInfo (state, userInfo) {
      state.userInfo = userInfo
    }
  },
  created () {
    this.getUserInfo()
  },
  actions: {
    async getUserInfo (context) {
      // const { data: res } = await this.$http.get('/my/userinfo')
      const { data: res } = await axios.get('/my/userinfo')
      // console.log(res)
      context.commit('updateUserInfo', res.data)
    }
  },
  getters: {}
}
